#############################
## BLIS/Swayable: Figure 7 ##
#############################

# File Description: 
# Uses data/packages from O_Data.R
# Replicates Figure 7 from Fabric of Repair report (2025)
# Date Last Updated: 2 May 2025

#############################

# Calculating movement support
df <- df %>%
  mutate(support_reparations = ifelse(rep_baseline_categorical == "Support", 1, 0),
         support_landback = ifelse(landback_baseline_categorical == "Support", 1, 0))

# Calculating movememt feasibility
df <- df %>%
  mutate(lb_feasibility = ifelse(Feasibility.Land.Back == "Yes", 1, 0),
         r_feasibility = ifelse(Feasibility.Reparations == "Yes", 1, 0))

# Calculating Landback feasibility for Indigenous respondents, Reparations feasibility for Black respondents
df_own_movement_feasibility <- df %>%
  filter((race == "Indigenous" & support_landback == 1) | (race == "Black" & support_reparations == 1)) %>%
  mutate(hope = case_when(race == "Indigenous" ~ lb_feasibility,
                          race == "Black" ~ r_feasibility)) %>%
  group_by(race) %>%
  count(hope) %>% 
  mutate(Percentage = n/sum(n) * 100) %>%
  mutate(hope = ifelse(hope == 1, "Feasibile", "Hope Gap")) %>%
  mutate(movement = "Own Movement")

# Changing factor levels
df_own_movement_feasibility$hope <- factor(df_own_movement_feasibility$hope, levels = c("Hope Gap", "Feasibile"))

# Plotting Figure 7
df_own_movement_feasibility %>% 
  ggplot(aes(x = race, y = Percentage, fill = hope)) +
  geom_bar(stat = "identity") +
  labs(title = "Hope Gap",
       x = "Identity",
       y = "Percentage",
       fill = "Feasibility") +
  scale_y_continuous(labels = scales::percent_format(scale = 1)) +
  theme(axis.text.x = element_text(angle = 45)) +
  scale_fill_manual(values = c('#F35018', '#5AAE7D')) + 
  theme_bw()

